New upstream version 1.0.5+git20190530
authorBoyuan Yang <byang@debian.org>
Fri, 30 Aug 2019 15:18:48 +0000 (11:18 -0400)
committerBoyuan Yang <byang@debian.org>
Fri, 30 Aug 2019 15:18:48 +0000 (11:18 -0400)
18 files changed:
.travis.yml
README.md
appveyor.yml [new file with mode: 0644]
binding.gyp
data/dictionary/STPhrases.txt
node/binding.cc [deleted file]
node/dicts.gypi
node/node_binding.gypi [deleted file]
node/node_opencc.gypi [new file with mode: 0644]
node/opencc.cc [new file with mode: 0644]
node/opencc.js
package.json
src/BinaryDict.cpp
src/DartsDict.cpp
src/DictConverter.hpp
src/Exception.hpp
src/PhraseExtractTest.cpp
src/TextDict.cpp

index 676a238883ec387824e59ecd0e9b1dc0ad75f63a..7f71b243abfc6db84cc0b8d38a1c1e2d3ab9f974 100644 (file)
@@ -1,13 +1,42 @@
-language: cpp
-compiler:
-  - gcc
-sudo: required
-before_install:
-  - sudo add-apt-repository -y ppa:chris-lea/node.js
-  - sudo apt-get update
-  - sudo apt-get install nodejs -y
-  - sudo apt-get install doxygen -y
-  - sudo npm install -g mocha
-  - sudo npm install -g node-gyp
-  - sudo npm install
-script: make test VERBOSE=1 && make package VERBOSE=1 && make node-test
+language: node_js
+
+cache:
+  npm: true
+  ccache: true
+
+node_js:
+  - stable
+  - 10
+  - 8
+  - 6
+
+os:
+  - linux
+  - osx
+
+addons:
+  apt:
+    sources:
+      - ubuntu-toolchain-r-test
+    packages:
+      - doxygen
+      - g++-4.8
+
+# Install scripts. (runs after repo cloning)
+install:
+  - if [ $TRAVIS_OS_NAME == "linux" ]; then export CXX=g++-4.8; fi
+  # install modules
+  - npm install --build-from-source
+
+# Post-install test scripts.
+script:
+  - export PATH="/usr/lib/ccache/:$PATH"
+  - if [ $TRAVIS_OS_NAME == "linux" ] && [ $TRAVIS_NODE_VERSION == "stable" ]; then
+      make test VERBOSE=1;
+      make package VERBOSE=1;
+    fi
+
+  - npm test
+
+after_success:
+  - npm run deploy
index 993034073ad93edd751ce2d0a09fc9c866c73238..855155815bbc00ea30ade2555e285b93440e6c22 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
 # Open Chinese Convert 開放中文轉換
 
 [ ![Download](https://api.bintray.com/packages/byvoid/opencc/OpenCC/images/download.svg) ](https://bintray.com/byvoid/opencc/OpenCC/_latestVersion)
-[![Build Status](https://travis-ci.org/BYVoid/OpenCC.svg?branch=master)](https://travis-ci.org/BYVoid/OpenCC)
+[![Travis](https://img.shields.io/travis/BYVoid/OpenCC.svg)](https://travis-ci.org/BYVoid/OpenCC)
+[![AppVeyor](https://img.shields.io/appveyor/ci/Carbo/OpenCC.svg)](https://ci.appveyor.com/project/Carbo/OpenCC)
 
 ## Introduction 介紹
 
@@ -99,19 +100,20 @@ cmake --build build --config Release --target install
 
 See https://github.com/gelosie/OpenCC/tree/master/iOS
 
+Or [SwiftyOpenCC](https://github.com/XQS6LB3A/SwiftyOpenCC)
+
 ### Android
 
 See [android-opencc](https://github.com/qichuan/android-opencc)
 
 ## Projects using Opencc 使用OpenCC的項目
 
-* [ibus-pinyin](http://code.google.com/p/ibus/)
-* [fcitx](http://code.google.com/p/fcitx/)
-* [rimeime](http://code.google.com/p/rimeime/)
+* [ibus-pinyin](https://github.com/ibus/ibus-pinyin)
+* [fcitx](https://github.com/fcitx/fcitx)
+* [rimeime](https://rime.im/)
 * [libgooglepinyin](http://code.google.com/p/libgooglepinyin/)
 * [ibus-libpinyin](https://github.com/libpinyin/ibus-libpinyin)
 * [BYVBlog](https://github.com/byvoid/byvblog)
-* [豆瓣同城微信](http://weixinqiao.com/douban-event/)
 * [alfred-chinese-converter](https://github.com/amowu/alfred-chinese-converter)
 * [GoldenDict](https://github.com/goldendict/goldendict)
 
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644 (file)
index 0000000..599ad6e
--- /dev/null
@@ -0,0 +1,40 @@
+version: "{build}"
+skip_branch_with_pr: true
+skip_tags: true
+build: off
+
+environment:
+  matrix:
+    - nodejs_version: stable
+    - nodejs_version: 10
+    - nodejs_version: 8
+    - nodejs_version: 6
+
+platform:
+  - x64
+  - x86
+
+# Install scripts. (runs after repo cloning)
+install:
+  # install Node.js
+  - ps: Install-Product node $env:nodejs_version $env:platform
+  # Get the latest stable version of npm
+  - npm -g i npm@latest
+  # install modules
+  - appveyor-retry call npm install --build-from-source
+
+# to run your custom scripts instead of automatic tests
+test_script:
+  - IF %nodejs_version%==stable cmake -H. -Bbuild -G"Visual Studio 12"
+  - IF %nodejs_version%==stable cmake --build build --config Release --target install
+  - npm test
+
+# pushing entire folder as a zip archive
+artifacts:
+  - path: build/src/tools/Release
+    name: OpenCC
+    type: zip
+
+# to run your custom scripts instead of provider deployments
+deploy_script:
+  - npm run deploy
index 89ae598c33eece5e8da094c7465ed546504148c9..ccc7a0fa6409b22fc3312a6ce7a51188b886fcc9 100644 (file)
@@ -3,6 +3,6 @@
     "node/global.gypi",
     "node/configs.gypi",
     "node/dicts.gypi",
-    "node/node_binding.gypi",
+    "node/node_opencc.gypi",
   ]
 }
index 28f14fd23c5c88122f54b59b87e007861c1904d0..141d1374961cb2f0bf44e37935eed9259e997b55 100644 (file)
 化学工厂   化學工廠
 化学弹药   化學彈藥
 化学当量   化學當量
-化学战斗部        化學戰
+化学战斗部        化學戰
 化学系      化學系
 化学纤维   化學纖維
 化工厂      化工廠
 杨胜旭      楊勝旭
 杨致远      楊致遠
 杨苏棣      楊甦棣
-杨采妮      楊
+杨采妮      楊
 杨雅筑      楊雅筑
 杪秋 杪秋
 杭丁顿舞蹈症     杭丁頓舞蹈症
 核当量      核當量
 核心 核心
 核战 核戰
-核战斗部   核戰
+核战斗部   核戰
 核批 覈批
 核技术      核技術
 核报 覈報
 间深里      間深裏
 闵凶 閔凶
 闵子里      閔子裏
-闵采尔      閔
+闵采尔      閔
 闷出 悶出
 闷在心里   悶在心裏
 闷板 悶板
diff --git a/node/binding.cc b/node/binding.cc
deleted file mode 100644 (file)
index b948e55..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-#include <iostream>
-#include <nan.h>
-
-#include "Config.hpp"
-#include "Converter.hpp"
-#include "DictConverter.hpp"
-
-// For faster build
-#include "BinaryDict.cpp"
-#include "Config.cpp"
-#include "Conversion.cpp"
-#include "ConversionChain.cpp"
-#include "Converter.cpp"
-#include "DartsDict.cpp"
-#include "Dict.cpp"
-#include "DictConverter.cpp"
-#include "DictEntry.cpp"
-#include "DictGroup.cpp"
-#include "MaxMatchSegmentation.cpp"
-#include "Segmentation.cpp"
-#include "TextDict.cpp"
-#include "UTF8Util.cpp"
-
-using namespace opencc;
-
-string ToUtf8String(const v8::Local<v8::Value>& val) {
-  Nan::Utf8String utf8(val);
-  return string(*utf8);
-}
-
-class OpenccBinding : public Nan::ObjectWrap {
-  struct ConvertRequest {
-    OpenccBinding* instance;
-    string input;
-    string output;
-    Nan::Callback *callback;
-    Optional<opencc::Exception> ex;
-
-    ConvertRequest()
-        : instance(nullptr), ex(Optional<opencc::Exception>::Null()) {
-    }
-  };
-
-  Config config_;
-  const ConverterPtr converter_;
- public:
-  explicit OpenccBinding(const string configFileName)
-    : config_(),
-      converter_(config_.NewFromFile(configFileName)) {}
-
-  virtual ~OpenccBinding() {
-  }
-
-  string Convert(const string& input) {
-    return converter_->Convert(input);
-  }
-
-  static NAN_METHOD(Version) {
-    info.GetReturnValue().Set(Nan::New<v8::String>(VERSION).ToLocalChecked());
-  }
-
-  static NAN_METHOD(New) {
-    OpenccBinding* instance;
-
-    try {
-      if (info.Length() >= 1 && info[0]->IsString()) {
-        const string configFile = ToUtf8String(info[0]);
-        instance = new OpenccBinding(configFile);
-      } else {
-        instance = new OpenccBinding("s2t.json");
-      }
-    } catch (opencc::Exception& e) {
-      Nan::ThrowError(e.what());
-      return;
-    }
-
-    instance->Wrap(info.This());
-    info.GetReturnValue().Set(info.This());
-  }
-
-  static NAN_METHOD(Convert) {
-    if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) {
-      Nan::ThrowTypeError("Wrong arguments");
-      return;
-    }
-
-    ConvertRequest* conv_data = new ConvertRequest;
-    conv_data->instance = Nan::ObjectWrap::Unwrap<OpenccBinding>(info.This());
-    conv_data->input = ToUtf8String(info[0]);
-    conv_data->callback = new Nan::Callback(info[1].As<v8::Function>());
-    conv_data->ex = Optional<opencc::Exception>::Null();
-    uv_work_t* req = new uv_work_t;
-    req->data = conv_data;
-    uv_queue_work(uv_default_loop(), req, DoConvert, (uv_after_work_cb)AfterConvert);
-
-    return;
-  }
-
-  static void DoConvert(uv_work_t* req) {
-    ConvertRequest* conv_data = static_cast<ConvertRequest*>(req->data);
-    OpenccBinding* instance = conv_data->instance;
-    try {
-      conv_data->output = instance->Convert(conv_data->input);
-    } catch (opencc::Exception& e) {
-      conv_data->ex = Optional<opencc::Exception>(e);
-    }
-  }
-
-  static void AfterConvert(uv_work_t* req) {
-    Nan::HandleScope scope;
-    ConvertRequest* conv_data = static_cast<ConvertRequest*>(req->data);
-    v8::Local<v8::Value> err = Nan::Undefined();
-    v8::Local<v8::String> converted = Nan::New(conv_data->output.c_str()).ToLocalChecked();
-    if (!conv_data->ex.IsNull()) {
-      err = Nan::New(conv_data->ex.Get().what()).ToLocalChecked();
-    }
-    const unsigned argc = 2;
-    v8::Local<v8::Value> argv[argc] = {
-      err,
-      converted
-    };
-    conv_data->callback->Call(argc, argv);
-    delete conv_data;
-    delete req;
-  }
-
-  static NAN_METHOD(ConvertSync) {
-    if (info.Length() < 1 || !info[0]->IsString()) {
-      Nan::ThrowTypeError("Wrong arguments");
-      return;
-    }
-
-    OpenccBinding* instance = Nan::ObjectWrap::Unwrap<OpenccBinding>(info.This());
-
-    const string input = ToUtf8String(info[0]);
-    string output;
-    try {
-      output = instance->Convert(input);
-    } catch (opencc::Exception& e) {
-      Nan::ThrowError(e.what());
-      return;
-    }
-
-    v8::Local<v8::String> converted = Nan::New(output.c_str()).ToLocalChecked();
-    info.GetReturnValue().Set(converted);
-  }
-
-  static NAN_METHOD(GenerateDict) {
-    if (info.Length() < 4 || !info[0]->IsString() || !info[1]->IsString()
-       || !info[2]->IsString() || !info[3]->IsString()) {
-      Nan::ThrowTypeError("Wrong arguments");
-      return;
-    }
-    const string inputFileName = ToUtf8String(info[0]);
-    const string outputFileName = ToUtf8String(info[1]);
-    const string formatFrom = ToUtf8String(info[2]);
-    const string formatTo = ToUtf8String(info[3]);
-    try {
-      opencc::ConvertDictionary(inputFileName, outputFileName, formatFrom, formatTo);
-    } catch (opencc::Exception& e) {
-      Nan::ThrowError(e.what());
-    }
-  }
-
-  static NAN_MODULE_INIT(Init) {
-    // Prepare constructor template
-    v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(OpenccBinding::New);
-    tpl->SetClassName(Nan::New("Opencc").ToLocalChecked());
-    tpl->InstanceTemplate()->SetInternalFieldCount(1);
-    // Methods
-    Nan::SetMethod(tpl, "version", Version);
-    Nan::SetMethod(tpl, "generateDict", GenerateDict);
-    // Prototype
-    Nan::SetPrototypeMethod(tpl, "convert", Convert);
-    Nan::SetPrototypeMethod(tpl, "convertSync", ConvertSync);
-    // Constructor
-    v8::Local<v8::Function> cons = Nan::GetFunction(tpl).ToLocalChecked();
-    Nan::Set(target, Nan::New("Opencc").ToLocalChecked(), cons);
-  }
-};
-
-NODE_MODULE(binding, OpenccBinding::Init);
index 3b96381eabe41e022591804897b9b5d29ebeec5c..0ea3452652ae3b61b040d6e5f319592cde9bdd1e 100644 (file)
       "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"]
     }],
     "dependencies": [
-      "binding"
+      "opencc"
     ]
   }]
 }
diff --git a/node/node_binding.gypi b/node/node_binding.gypi
deleted file mode 100644 (file)
index 6022195..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-  "targets": [{
-    "target_name": "binding",
-    "sources": [
-      "../node/binding.cc",
-    ],
-    "include_dirs": [
-      "../src",
-      "../deps/darts-clone",
-      "../deps/rapidjson-0.11",
-      "<!(node -e \"require('nan')\")"
-    ]
-  }]
-}
diff --git a/node/node_opencc.gypi b/node/node_opencc.gypi
new file mode 100644 (file)
index 0000000..2db8fdd
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "targets": [{
+    "target_name": "opencc",
+    "sources": [
+      "../node/opencc.cc",
+    ],
+    "include_dirs": [
+      "../src",
+      "../deps/darts-clone",
+      "../deps/rapidjson-0.11",
+      "<!(node -e \"require('nan')\")"
+    ]
+  }]
+}
diff --git a/node/opencc.cc b/node/opencc.cc
new file mode 100644 (file)
index 0000000..b948e55
--- /dev/null
@@ -0,0 +1,182 @@
+#include <iostream>
+#include <nan.h>
+
+#include "Config.hpp"
+#include "Converter.hpp"
+#include "DictConverter.hpp"
+
+// For faster build
+#include "BinaryDict.cpp"
+#include "Config.cpp"
+#include "Conversion.cpp"
+#include "ConversionChain.cpp"
+#include "Converter.cpp"
+#include "DartsDict.cpp"
+#include "Dict.cpp"
+#include "DictConverter.cpp"
+#include "DictEntry.cpp"
+#include "DictGroup.cpp"
+#include "MaxMatchSegmentation.cpp"
+#include "Segmentation.cpp"
+#include "TextDict.cpp"
+#include "UTF8Util.cpp"
+
+using namespace opencc;
+
+string ToUtf8String(const v8::Local<v8::Value>& val) {
+  Nan::Utf8String utf8(val);
+  return string(*utf8);
+}
+
+class OpenccBinding : public Nan::ObjectWrap {
+  struct ConvertRequest {
+    OpenccBinding* instance;
+    string input;
+    string output;
+    Nan::Callback *callback;
+    Optional<opencc::Exception> ex;
+
+    ConvertRequest()
+        : instance(nullptr), ex(Optional<opencc::Exception>::Null()) {
+    }
+  };
+
+  Config config_;
+  const ConverterPtr converter_;
+ public:
+  explicit OpenccBinding(const string configFileName)
+    : config_(),
+      converter_(config_.NewFromFile(configFileName)) {}
+
+  virtual ~OpenccBinding() {
+  }
+
+  string Convert(const string& input) {
+    return converter_->Convert(input);
+  }
+
+  static NAN_METHOD(Version) {
+    info.GetReturnValue().Set(Nan::New<v8::String>(VERSION).ToLocalChecked());
+  }
+
+  static NAN_METHOD(New) {
+    OpenccBinding* instance;
+
+    try {
+      if (info.Length() >= 1 && info[0]->IsString()) {
+        const string configFile = ToUtf8String(info[0]);
+        instance = new OpenccBinding(configFile);
+      } else {
+        instance = new OpenccBinding("s2t.json");
+      }
+    } catch (opencc::Exception& e) {
+      Nan::ThrowError(e.what());
+      return;
+    }
+
+    instance->Wrap(info.This());
+    info.GetReturnValue().Set(info.This());
+  }
+
+  static NAN_METHOD(Convert) {
+    if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) {
+      Nan::ThrowTypeError("Wrong arguments");
+      return;
+    }
+
+    ConvertRequest* conv_data = new ConvertRequest;
+    conv_data->instance = Nan::ObjectWrap::Unwrap<OpenccBinding>(info.This());
+    conv_data->input = ToUtf8String(info[0]);
+    conv_data->callback = new Nan::Callback(info[1].As<v8::Function>());
+    conv_data->ex = Optional<opencc::Exception>::Null();
+    uv_work_t* req = new uv_work_t;
+    req->data = conv_data;
+    uv_queue_work(uv_default_loop(), req, DoConvert, (uv_after_work_cb)AfterConvert);
+
+    return;
+  }
+
+  static void DoConvert(uv_work_t* req) {
+    ConvertRequest* conv_data = static_cast<ConvertRequest*>(req->data);
+    OpenccBinding* instance = conv_data->instance;
+    try {
+      conv_data->output = instance->Convert(conv_data->input);
+    } catch (opencc::Exception& e) {
+      conv_data->ex = Optional<opencc::Exception>(e);
+    }
+  }
+
+  static void AfterConvert(uv_work_t* req) {
+    Nan::HandleScope scope;
+    ConvertRequest* conv_data = static_cast<ConvertRequest*>(req->data);
+    v8::Local<v8::Value> err = Nan::Undefined();
+    v8::Local<v8::String> converted = Nan::New(conv_data->output.c_str()).ToLocalChecked();
+    if (!conv_data->ex.IsNull()) {
+      err = Nan::New(conv_data->ex.Get().what()).ToLocalChecked();
+    }
+    const unsigned argc = 2;
+    v8::Local<v8::Value> argv[argc] = {
+      err,
+      converted
+    };
+    conv_data->callback->Call(argc, argv);
+    delete conv_data;
+    delete req;
+  }
+
+  static NAN_METHOD(ConvertSync) {
+    if (info.Length() < 1 || !info[0]->IsString()) {
+      Nan::ThrowTypeError("Wrong arguments");
+      return;
+    }
+
+    OpenccBinding* instance = Nan::ObjectWrap::Unwrap<OpenccBinding>(info.This());
+
+    const string input = ToUtf8String(info[0]);
+    string output;
+    try {
+      output = instance->Convert(input);
+    } catch (opencc::Exception& e) {
+      Nan::ThrowError(e.what());
+      return;
+    }
+
+    v8::Local<v8::String> converted = Nan::New(output.c_str()).ToLocalChecked();
+    info.GetReturnValue().Set(converted);
+  }
+
+  static NAN_METHOD(GenerateDict) {
+    if (info.Length() < 4 || !info[0]->IsString() || !info[1]->IsString()
+       || !info[2]->IsString() || !info[3]->IsString()) {
+      Nan::ThrowTypeError("Wrong arguments");
+      return;
+    }
+    const string inputFileName = ToUtf8String(info[0]);
+    const string outputFileName = ToUtf8String(info[1]);
+    const string formatFrom = ToUtf8String(info[2]);
+    const string formatTo = ToUtf8String(info[3]);
+    try {
+      opencc::ConvertDictionary(inputFileName, outputFileName, formatFrom, formatTo);
+    } catch (opencc::Exception& e) {
+      Nan::ThrowError(e.what());
+    }
+  }
+
+  static NAN_MODULE_INIT(Init) {
+    // Prepare constructor template
+    v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(OpenccBinding::New);
+    tpl->SetClassName(Nan::New("Opencc").ToLocalChecked());
+    tpl->InstanceTemplate()->SetInternalFieldCount(1);
+    // Methods
+    Nan::SetMethod(tpl, "version", Version);
+    Nan::SetMethod(tpl, "generateDict", GenerateDict);
+    // Prototype
+    Nan::SetPrototypeMethod(tpl, "convert", Convert);
+    Nan::SetPrototypeMethod(tpl, "convertSync", ConvertSync);
+    // Constructor
+    v8::Local<v8::Function> cons = Nan::GetFunction(tpl).ToLocalChecked();
+    Nan::Set(target, Nan::New("Opencc").ToLocalChecked(), cons);
+  }
+};
+
+NODE_MODULE(binding, OpenccBinding::Init);
index 70f95642659c63c0f7651c6062d98d5d19127c88..67be63f6448be3228744793b04c073b5cef5f12b 100644 (file)
  */
 
 var path = require('path');
-var binding = require('../build/Release/binding');
+var bindingPath = require('node-pre-gyp').find(require.resolve('../package.json'));
+var binding = require(bindingPath);
 
-var assetsPath = path.resolve(__dirname, '../build/Release');
+var assetsPath = path.dirname(bindingPath);
 var getConfigPath = function (config) {
   var configPath = config;
   if (config[0] !== '/' && config[1] !== ':') {
index 4d7233b393af91544e47a4dd5b406b0644923567..77e9aeae5fe80dff17aeb2462065e2df631e86ba 100644 (file)
@@ -6,7 +6,15 @@
   "license": "Apache-2.0",
   "main": "node/opencc.js",
   "scripts": {
-    "test": "mocha -R spec node/test.js"
+    "test": "mocha -R spec node/test.js",
+    "deploy": "node-pre-gyp package && (node-pre-gyp-github publish --release || exit 0)",
+    "install": "node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild"
+  },
+  "binary": {
+    "module_name": "opencc",
+    "module_path": "./build/Release/",
+    "host": "https://github.com/BYVoid/OpenCC/releases/download/",
+    "remote_path": "{version}"
   },
   "repository": {
     "type": "git",
     "Traditional Chinese"
   ],
   "devDependencies": {
-    "mocha": "2.2.5"
+    "mocha": "^3.5.0",
+    "node-pre-gyp-github": "^1.3.1"
   },
   "dependencies": {
-    "nan": "^2.5.1"
+    "nan": "^2.7.0",
+    "node-pre-gyp": "^0.6.36"
   }
 }
index 87a215d57bada835c813699cd87f23a2fe7d6ed7..bfeb3ac3d12fb966a7d746abdd04b72865919772 100644 (file)
@@ -24,7 +24,7 @@ using namespace opencc;
 size_t BinaryDict::KeyMaxLength() const {
   size_t maxLength = 0;
   for (const DictEntry* entry : *lexicon) {
-    maxLength = std::max(maxLength, entry->KeyLength());
+    maxLength = (std::max)(maxLength, entry->KeyLength());
   }
   return maxLength;
 }
index 75f4c3ddf8046855462db7de1a0895602088997d..07ebec8dc279d45a219dfffb16a6da871ca75aa9 100644 (file)
@@ -135,7 +135,7 @@ DartsDictPtr DartsDict::NewFromDict(const Dict& thatDict) {
   for (size_t i = 0; i < lexiconCount; i++) {
     const DictEntry* entry = lexicon->At(i);
     keys[i] = entry->Key();
-    maxLength = std::max(entry->KeyLength(), maxLength);
+    maxLength = (std::max)(entry->KeyLength(), maxLength);
   }
   doubleArray->build(lexicon->Length(), &keys[0]);
   dict->lexicon = lexicon;
index f59c5ec5aa6462b4c95dc586e5319a9c6de2d830..7d392a1e254a4624e30baba5d23a761d1e2d3148 100644 (file)
@@ -25,6 +25,6 @@ namespace opencc {
 * Converts a dictionary from a format to another.
 * @ingroup opencc_cpp_api
 */
-void ConvertDictionary(const string inputFileName, const string outputFileName,
+OPENCC_EXPORT void ConvertDictionary(const string inputFileName, const string outputFileName,
                        const string formatFrom, const string formatTo);
 }
index 33cb5d9d9a36ae36fe33e231cebe575fadf0981e..98ebb605468ad0ce8981c67d67ae6243c24bff94 100644 (file)
@@ -24,9 +24,8 @@
 
 #include "Export.hpp"
 
-#ifdef _MSC_VER
-
-// Until Visual Studio 2013 (12.0), C++ 11 "noexcept" qualifier is not supported
+#if defined(_MSC_VER) && _MSC_VER < 1900
+// Before Visual Studio 2015 (14.0), C++ 11 "noexcept" qualifier is not supported
 #define noexcept
 #endif // ifdef _MSC_VER
 
index 3eced583f92bfa6d503858f98bdb28db01d43a99..e1c8fef58c60d901b6e93a583fabd7f61a9b1ae1 100644 (file)
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+#include <cmath>
+
 #include "PhraseExtract.hpp"
 #include "TestUtils.hpp"
 
index a6d29f35a7316844da74837bf49b7162e10f275b..73f5119c2898c79e528cf62b0fc766aac407593b 100644 (file)
@@ -25,7 +25,7 @@ static size_t GetKeyMaxLength(const LexiconPtr& lexicon) {
   size_t maxLength = 0;
   for (const auto& entry : *lexicon) {
     size_t keyLength = entry->KeyLength();
-    maxLength = std::max(keyLength, maxLength);
+    maxLength = (std::max)(keyLength, maxLength);
   }
   return maxLength;
 }